﻿tTrawler.helper = {
  
  replaceAll : function (needle, replace, hayStack) {
    for(kk in needle) {
      while (hayStack.indexOf(needle[kk]) > 0) {
        hayStack = hayStack.replace(needle[kk], replace[kk]);
      };
    };
    return hayStack;
  },
  
  inArray : function (needle, hayStack) {
    var r = false;
    for(x in hayStack) {
      if (needle == hayStack[x]) {
        r = true;
        break;
      };
    };
    return r;
  },
  
  getTorrentHealth : function (seeds, leeches) {
    // eww...
    var r ="torrent-health-0";
    if(seeds <= 5 && seeds > 0) { r = "torrent-health-1"};
    if(seeds > 5 && seeds <= 10) { r = "torrent-health-2"};
    if(seeds > 10 && seeds <= 15) { r = "torrent-health-3"};
    if(seeds > 15 && seeds <= 20) { r = "torrent-health-4"};
    if(seeds > 20 ) { r = "torrent-health-5"};
    return r;
  }
  /*--*/
}